/*
 * BncsAuthCheckServer.h
 *
 *  Created on: Nov 20, 2008
 *      Author: nathan
 */

#ifndef BNCSAUTHCHECKSERVER_H_
#define BNCSAUTHCHECKSERVER_H_

#include "BncsMessage.h"
#include "BncsMessageFactory.h"

class BncsAuthCheckServerData : public QSharedData
{
public:
	quint32 result;
	QByteArray additionalInfo;
};

class BncsAuthCheckServer : public BncsMessage
{
	BNCS_MESSAGE_REGISTER(BncsAuthCheckServer, 0x51);

public:
	QSharedDataPointer<BncsAuthCheckServerData> d;

public:
	quint32 id()
	{
		return id;
	}

	int size()
	{
		return sizeof(d->result) + (d->additionalInfo.size() + 1);
	}

	void readFrom(QDataStream& ds)
	{
		int bo = ds.byteOrder();
		ds.setByteOrder(QDataStream::LittleEndian);

		ds >> result;
		additionalInfo = readStringFrom(ds);

		ds.setByteOrder((QDataStream::ByteOrder)bo);
	}

	void writeTo(QDataStream& ds)
	{
		int bo = ds.byteOrder();
		ds.setByteOrder(QDataStream::LittleEndian);

		ds << result;
		writeStringTo(ds, additionalInfo);

		ds.setByteOrder((QDataStream::ByteOrder)bo);
	}
};


#endif /* BNCSAUTHCHECKSERVER_H_ */
